﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace ProjectPigs.Assets
{
    public class Transform
    {
        Quaternion quat;

        Vector3 position;
        Vector3 scale;
        Vector3 rotation;

        Vector3 upVector = Vector3.Up ;
        Vector3 lookVector = Vector3.Forward ;

        public Vector3 UpVector { get { return upVector; } }
        public Vector3 LookVector { get { return lookVector; } }


        public void setPosition_X(float x) { position.X = x; }
        public void setPosition_Y(float y) { position.Y = y; }
        public void setPosition_Z(float z) { position.Z = z; }
        public void setRotation_X(float x) { rotation.X = x; }
        public void setRotation_Y(float y) { rotation.Y = y; }
        public void setRotation_Z(float z) { rotation.Z = z; }
        public void setScale_X(float x) { scale.X = x; }
        public void setScale_Y(float y) { scale.Y = y; }
        public void setScale_Z(float z) { scale.Z = z; }

        public void translate(Vector3 tr) { position += tr; }

        public Transform() { }

        public Transform(Vector3 position, Vector3 rotation, Vector3 scale)
        {
            this.position = new Vector3(position.X, position.Y, position.Z);
            this.rotation = new Vector3(rotation.X, rotation.Y, rotation.Z);
            this.scale = new Vector3(scale.X, scale.Y, scale.Z); ;
        }

        public Vector3 Position
        {
            get
            {
                return position;
            }
            set
            {
                this.position = value;
            }
    
        }

        public Vector3 Scale
        {
            get
            {
                return scale;
            }
            set
            {
                scale = value;
            }
        }

        public Vector3 Rotation
        {
            get
            {
                return rotation;
            }
            set
            {
                rotation = value;
            }
        }

        public void update()
        {
            updateTransforms();
        }

        private void updateTransforms()
        {

            upVector = Vector3.Transform(Vector3.Up, new Quaternion(rotation, 1));
            lookVector = Vector3.Transform(Vector3.Forward, new Quaternion(rotation, 1));
        }
    }
}
